package a;

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        System.out.println(isShan(a));
    }
    public static boolean isShan(int a[]){
        int n=a.length;
        int i=0,j=n-1;
        while(i<j){
            if(a[i+1]<=a[i]){
                return false;
            }
            if(a[j-1]<=a[j]){
                return false;
            }
            i++;
            j--;
        }
        //一直单调
        if(i==0||j==n-1){
            return false;
        }
        return true;
    }
}